package com.xiaolin.sports.controller;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xiaolin.sports.model.WechatMedia;
import com.xiaolin.sports.page.Page;
import com.xiaolin.sports.service.IWechatMeidaService;
import com.xiaolin.sports.vo.WechatMediaQueryVO;

@RequestMapping("media")
@Controller
public class WechatMediaController extends BaseController{
	
	private Logger logger = LoggerFactory.getLogger(WechatMediaController.class);

	@Autowired
	private IWechatMeidaService wechatMediaService;
	
	@RequestMapping("list")
	@ResponseBody Object mediaList(WechatMediaQueryVO vo){
		try {
			Page<WechatMedia> page = new Page<>();
			page.setPageNo(vo.getPage());
			if(vo.getAuthorType() != null) {
				page.setPageSize(Integer.MAX_VALUE - 1);
			}else {
				page.setPageSize(vo.getRows());
			}
			page.setParams(vo);
			List<WechatMedia> list = wechatMediaService.selectListByPage(page);
			page.setResults(list);
			return page;
		} catch (Exception e) {
			logger.error("----mediaList error={}", e);
		}
		return null;
	}
	
	@RequestMapping("coach")
	public String coach() {
		return "coach/coach";
	}
}
